import { handleAuthGetUserInfo, handleGetUserPhomeNumber } from '../../utils/wx'
import { isLogin, toLogin, getUserInfo, clearCacheAll } from '../../utils/auth'
import http from '../../utils/http'

Page({

    /**
     * 页面的初始数据
     */
    data: {
        userInfo: null,

        cecommendInfo: {
            cecommendCount: 0,
            cecommendAmount: 0,
            cecommendMemberList: [],
        }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        // 用户登录信息
        this.setData({ userInfo: getUserInfo() });

        this.getMyCecommend();
    },


    /**
     * 获取的推荐信息
     */
    async getMyCecommend() {
        let { userInfo } = this.data
        let res = await http.get('/api/mall/umsmember/myCecommend', { memberId: userInfo.id })

        if (res.status) {
            this.setData({ cecommendInfo: res.data })
        }
    },

    copyText(e) {
        wx.setClipboardData({
            data: e.currentTarget.dataset.text,
            success: function (res) {
                wx.getClipboardData({
                    success: function (res) {
                        wx.showToast({
                            title: '复制成功'
                        })
                    }
                })
            }
        })
    },

})